home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / var / lib / dpkg / info / alsa-base.postinst < prev    next >
Encoding:
Text File  |  2006-12-31  |  4.1 KB  |  152 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. MYNAME="$0"
  6.  
  7. # $* message
  8. warn() { echo "${MYNAME}: Warning: $*" >&2 ; }
  9.  
  10. # $* message
  11. report_error() { echo "${MYNAME}: Error: $*" >&2 ; }
  12.  
  13. # Move a conffile without triggering a dpkg question
  14. mv_conffile() {
  15.     OLDCONFFILE="$1"
  16.     NEWCONFFILE="$2"
  17.  
  18.     if [ -e "$OLDCONFFILE" ]; then
  19.         echo "Preserving user changes to $NEWCONFFILE"
  20.         mv -f "$NEWCONFFILE" "$NEWCONFFILE".dpkg-new
  21.         mv -f "$OLDCONFFILE" "$NEWCONFFILE"
  22.     elif [ -e "$OLDCONFFILE".dpkg-bak ]; then
  23.         rm -f "$OLDCONFFILE".dpkg-bak
  24.     fi
  25. }
  26.  
  27. devfs_is_active()
  28. {
  29.     test -e /dev/.devfsd
  30. }
  31.  
  32. kernel_is_2_6_or_above()
  33. {
  34.     case "$(uname -r)" in
  35.         1.*|2.[012345]*) return 1 ;;
  36.         *) return 0 ;;
  37.     esac
  38. }
  39.  
  40. udev_is_active()
  41. {
  42.     test -e /dev/.udev.tdb || test -d /dev/.udevdb || return 1
  43.     kernel_is_2_6_or_above || return 1
  44.     return 0
  45. }
  46.  
  47. case "$1" in
  48. configure|reconfigure)
  49.     if dpkg --compare-versions "$2" lt "1.0.10-4ubuntu2"; then
  50.         mv_conffile /etc/modprobe.d/alsa-base-blacklist \
  51.             /etc/modprobe.d/blacklist-modem
  52.  
  53.         rmdir /etc/alsa/modprobe-post-install.d 2>/dev/null || true
  54.         
  55.         rm -f /etc/discover.d/alsa-base
  56.         rmdir /etc/discover.d 2>/dev/null || true
  57.  
  58.         rm -f /etc/hotplug/blacklist.d/alsa-base
  59.         rmdir /etc/hotplug/blacklist.d 2>/dev/null || true
  60.  
  61.         rm -f /etc/modutils/alsa-base
  62.         rmdir /etc/modutils 2>/dev/null || true
  63.  
  64.         rm -f /etc/init.d/alsa
  65.     fi
  66.  
  67.     # Remove old obsolete configuration files
  68.     # (Keep this until etch)
  69.     if [ -d /etc/sound ]; then 
  70.         rmdir /etc/sound 2> /dev/null || :
  71.     fi
  72.     rm -f \
  73.         /etc/apm/event.d/alsa \
  74.         /etc/apm/event.d/alsa.dpkg-old \
  75.         /etc/default/alsa.debconf-backup \
  76.         /etc/devfs/conf.d/alsa \
  77.         /etc/discover.conf.d/10alsa \
  78.         /etc/discover.conf.d/10alsa.dpkg-old \
  79.         /etc/alsa/alsa-base.conf \
  80.         /etc/alsa/modutils/0.5 \
  81.         /etc/alsa/modutils/0.9 \
  82.         /etc/alsa/modutils/1.0 \
  83.         /etc/alsa/modutils/0.5.debconf-backup \
  84.         /etc/alsa/modutils/0.9.debconf-backup \
  85.         /etc/alsa/modutils/1.0.debconf-backup \
  86.         /etc/alsa/modprobe-post-install.d/alsa-base \
  87.         /etc/alsa/modprobe-post-install.d/alsa-base.dpkg-old \
  88.         /etc/modutils/alsa \
  89.         /etc/modutils/alsa-path \
  90.         /etc/modprobe.d/alsa    \
  91.         /etc/modprobe.d/sound
  92.     # Delete hotplug blacklist backup file since hotplug doesn't ignore
  93.     # it as it should (#299205)
  94.     rm -f \
  95.         /etc/hotplug/blacklist.d/alsa-base.dpkg-old
  96.     # Delete obsolete rc symlinks to alsa init.d script
  97.     # (update-rc.d produces an unnecessary warning message on stderr (see #164471) so print the error message only if its error status is nonzero)
  98.     STDERR="$(update-rc.d -f alsa remove 2>&1 >/dev/null)" || echo "Warning: 'update-rc.d -f alsa remove' reported: '$STDERR'." >&2
  99.     
  100.     # Decide which conf file to read
  101.     conf_file=""
  102.     if [ -f /etc/default/alsa ] ; then
  103.         conf_file=/etc/default/alsa
  104.     elif [ -f /usr/share/alsa-base/alsa.default ] ; then
  105.         conf_file=/usr/share/alsa-base/alsa.default
  106.     else
  107.         report_error "No configuration file found"
  108.         exit 1
  109.     fi
  110.     # Read variables from conf file
  111.     force_unload_modules_before_suspend="$( 
  112.         . "$conf_file" >/dev/null 2>&1
  113.         echo "$force_unload_modules_before_suspend"
  114.     )"
  115.     # Write new conf file
  116.     cat /usr/share/alsa-base/alsa.default | sed \
  117.         -e "s/force_unload_modules_before_suspend=.*/force_unload_modules_before_suspend=\"${force_unload_modules_before_suspend}\"/" \
  118.         > /etc/default/alsa
  119.     # Set up apm symlinks
  120.     [ -f /etc/apm/scripts.d/alsa ] || warn "/etc/apm/scripts.d/alsa is absent"
  121.     # $1: file to check
  122.     already_linked_to_alsa()
  123.     {
  124.         [ "$1" ] || return 1
  125.         [ -L "$1" ] || return 1
  126.         [ "$(basename "$(readlink "$1")")" = alsa ] || return 1
  127.         return 0
  128.     }
  129.     ALREADY_LINKED=no
  130.     for F in /etc/apm/suspend.d/??alsa ; do
  131.         already_linked_to_alsa "$F" && ALREADY_LINKED=yes && break
  132.     done
  133.     [ "$ALREADY_LINKED" = yes ] || ln -sf ../scripts.d/alsa /etc/apm/suspend.d/80alsa
  134.     ALREADY_LINKED=no
  135.     for F in /etc/apm/resume.d/??alsa ; do
  136.         already_linked_to_alsa "$F" && ALREADY_LINKED=yes && break
  137.     done
  138.     [ "$ALREADY_LINKED" = yes ] || ln -sf ../scripts.d/alsa /etc/apm/resume.d/20alsa
  139.     ;;
  140. abort-upgrade|abort-remove|abort-deconfigure)
  141.     # We don't have to do anything because we didn't do anything in prerm
  142.     exit 0
  143.     ;;
  144. *)
  145.     echo "postinst called with unknown argument \`$1'" >&2
  146.     exit 1
  147.     ;;
  148. esac
  149.  
  150.  
  151.  
  152.